import KoaRouter from 'koa-router'
import controllers from '../controllers/index.js'
import Contract from '../middleware/contract'
import Address from '../middleware/addressContract'

const router = new KoaRouter()
const contract = new Contract()
const address = new Address()
let user = contract.loadContract();

router
  .get('/public/createUser', async (ctx, next)=> {
    // let user = await address.createUser('lee');
    // let cion= await contract.createCoin(10000,bal.currentUserAddress);
    let user1 = await contract.createUser(1000);
    let zh = await contract.getAllUsers();
    ctx.body = user1
  }) // 以/public开头则不用经过权限认证
  .get('/api/:name', controllers.api.Get)
  .post('/api/:name', controllers.api.Post)
  .put('/api/:name', controllers.api.Put)
  .del('/api/:name', controllers.api.Delect)
  .post('/auth/:action', controllers.auth.Post)

module.exports = router
